{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Iris Dataset"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "A function that loads the `iris` dataset into NumPy arrays."
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "> from mlxtend.data import iris_data"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Overview"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "The Iris dataset for classification.\n",
    "\n",
    "**Features**\n",
    "\n",
    "1. Sepal length\n",
    "2. Sepal width\n",
    "3. Petal length\n",
    "4. Petal width\n",
    "\n",
    "\n",
    "- Number of samples: 150\n",
    "\n",
    "\n",
    "- Target variable (discrete): {50x Setosa, 50x Versicolor, 50x Virginica}\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### References\n",
    "\n",
    "- Source: [https://archive.ics.uci.edu/ml/datasets/Iris](https://archive.ics.uci.edu/ml/datasets/Iris) \n",
    "- Bache, K. & Lichman, M. (2013). UCI Machine Learning Repository. Irvine, CA: University of California, School of Information and Computer Science.\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Example 1 - Dataset overview"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dimensions: 150 x 4\n",
      "\n",
      "Header: ['sepal length', 'sepal width', 'petal length', 'petal width']\n",
      "1st row [5.1 3.5 1.4 0.2]\n"
     ]
    }
   ],
   "source": [
    "from mlxtend.data import iris_data\n",
    "X, y = iris_data()\n",
    "\n",
    "print('Dimensions: %s x %s' % (X.shape[0], X.shape[1]))\n",
    "print('\\nHeader: %s' % ['sepal length', 'sepal width',\n",
    "                        'petal length', 'petal width'])\n",
    "print('1st row', X[0])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Classes: Setosa, Versicolor, Virginica\n",
      "[0 1 2]\n",
      "Class distribution: [50 50 50]\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "print('Classes: Setosa, Versicolor, Virginica')\n",
    "print(np.unique(y))\n",
    "print('Class distribution: %s' % np.bincount(y))"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## API"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "## iris_data\n",
      "\n",
      "*iris_data(version='uci')*\n",
      "\n",
      "Iris flower dataset.\n",
      "\n",
      "\n",
      "- `Source` : https://archive.ics.uci.edu/ml/datasets/Iris\n",
      "\n",
      "\n",
      "- `Number of samples` : 150\n",
      "\n",
      "\n",
      "- `Class labels` : {0, 1, 2}, distribution: [50, 50, 50]\n",
      "\n",
      "    0 = setosa, 1 = versicolor, 2 = virginica.\n",
      "\n",
      "    Dataset Attributes:\n",
      "\n",
      "    - 1) sepal length [cm]\n",
      "    - 2) sepal width [cm]\n",
      "    - 3) petal length [cm]\n",
      "    - 4) petal width [cm]\n",
      "\n",
      "\n",
      "**Parameters**\n",
      "\n",
      "- `version` : string, optional (default: 'uci').\n",
      "\n",
      "    Version to use {'uci', 'corrected'}. 'uci' loads the dataset\n",
      "    as deposited on the UCI machine learning repository, and\n",
      "    'corrected' provides the version that is consistent with\n",
      "    Fisher's original paper. See Note for details.\n",
      "\n",
      "\n",
      "**Returns**\n",
      "\n",
      "- `X, y` : [n_samples, n_features], [n_class_labels]\n",
      "\n",
      "    X is the feature matrix with 150 flower samples as rows,\n",
      "    and 4 feature columns sepal length, sepal width,\n",
      "    petal length, and petal width.\n",
      "    y is a 1-dimensional array of the class labels {0, 1, 2}\n",
      "\n",
      "\n",
      "**Note**\n",
      "\n",
      "The Iris dataset (originally collected by Edgar Anderson) and\n",
      "    available in UCI's machine learning repository is different from\n",
      "    the Iris dataset described in the original paper by  R.A. Fisher [1]).\n",
      "    Precisely, there are two data points (row number\n",
      "    34 and 37) in UCI's Machine Learning repository are different from the\n",
      "    origianlly published Iris dataset. Also, the original version of the Iris\n",
      "    Dataset, which can be loaded via `version='corrected'` is the same\n",
      "    as the one in R.\n",
      "\n",
      "    [1] . A. Fisher (1936). \"The use of multiple measurements in taxonomic\n",
      "    problems\". Annals of Eugenics. 7 (2): 179–188\n",
      "\n",
      "**Examples**\n",
      "\n",
      "For usage examples, please see\n",
      "    [http://rasbt.github.io/mlxtend/user_guide/data/iris_data/](http://rasbt.github.io/mlxtend/user_guide/data/iris_data/)\n",
      "\n",
      "\n"
     ]
    }
   ],
   "source": [
    "with open('../../api_modules/mlxtend.data/iris_data.md', 'r') as f:\n",
    "    print(f.read())"
   ]
  }
 ],
 "metadata": {
  "anaconda-cloud": {},
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.1"
  },
  "toc": {
   "nav_menu": {},
   "number_sections": true,
   "sideBar": true,
   "skip_h1_title": false,
   "title_cell": "Table of Contents",
   "title_sidebar": "Contents",
   "toc_cell": false,
   "toc_position": {},
   "toc_section_display": true,
   "toc_window_display": false
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
